﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for DepartmentModel
/// </summary>
public class DepartmentModel : SQLAccess
{
	public DepartmentModel()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public DataTable getDepartment(){        
        String sql = "SELECT * FROM Departments";
        DataTable table = this.executeQuery(sql);
        
        return table;
    }

    public bool update(DepartmentsDTO department) {
        if (connect()) { //if connect successful
            String sql = "Update Paramenters SET Name = @name WHERE DepartmentID = @id";
            _command = new System.Data.SqlClient.SqlCommand(sql, _conn);
            _command.CommandType = CommandType.Text;

            _command.Parameters.Add(new SqlParameter("@name", department.Name));
            _command.Parameters.Add(new SqlParameter("@id", department.DepartmentID));
            
            //execute query
            _command.ExecuteNonQuery();            

            disconnect();
        }

        return false;
    }
}